import dict from '@/const/dict/dict';

export default {
  height: 'auto',
  calcHeight: 30,
  tip: false,
  searchShow: true,
  border: true,
  index: true,
  viewBtn: true,
  selection: true,
  dialogClickModal: false,
  grid: false,
  gridBtn: false,
  dialogDrag: true,
  defaultSort: {
    prop: 'createTime',
    order: 'descending'
  },
  column: [
    {
      label: '主键',
      prop: 'id',
      type: 'input',
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      hide: true
    },
    {
      label: '代理平台',
      prop: 'proxyPlatformId',
      type: 'select',
      dicUrl: '/biz/search/select/proxy-platform',
      dicHeaders: { crypto: true },
      dicMethod: 'post',
      dataType: 'string',
      props: {
        label: 'dictValue',
        value: 'dictKey'
      },
      search: true,
      searchSpan: 4,
      searchLabelWidth: 100,
      rules: [{
        required: true,
        message: '请输入代理平台',
        trigger: 'blur'
      }]
    },
    {
      label: '产品类型',
      prop: 'productType',
      type: 'select',
      dicUrl: '/biz/search/dictionary/dict-biz',
      dicHeaders: { crypto: true },
      dicQuery: { code: 'proxy_product' },
      dicMethod: 'post',
      dataType: 'number',
      props: {
        label: 'dictValue',
        value: 'dictKey'
      },
      value: 1,
      search: true,
      searchSpan: 4,
      searchLabelWidth: 100,
      rules: [{
        required: true,
        message: '请输入产品类型',
        trigger: 'blur'
      }]
    },
    {
      label: '价格/GB',
      prop: 'price',
      type: 'input'
    },
    {
      label: '账密/API',
      prop: 'proxyMethod',
      type: 'select',
      control: (val, form) => {
        if (val === 1) {
          return {
            directConnection: {
              display: false
            }
          };
        } else {
          return {
            directConnection: {
              display: true
            }
          };
        }
      },
      dicUrl: '/biz/search/dictionary/dict-biz',
      dicHeaders: { crypto: true },
      dicQuery: { code: 'proxy_method' },
      dicMethod: 'post',
      dataType: 'number',
      props: {
        label: 'dictValue',
        value: 'dictKey'
      },
      value: 1,
      search: true,
      searchSpan: 4,
      searchLabelWidth: 100,
      rules: [{
        required: true,
        message: '请输入账密/API',
        trigger: 'blur'
      }],
    },
    {
      label: '协议方式',
      prop: 'proxyProtocol',
      type: 'select',
      dicUrl: '/biz/search/dictionary/dict-biz',
      dicHeaders: { crypto: true },
      dicQuery: { code: 'proxy_protocol' },
      dicMethod: 'post',
      dataType: 'number',
      props: {
        label: 'dictValue',
        value: 'dictKey'
      },
      value: 1,
      search: true,
      searchSpan: 4,
      searchLabelWidth: 100,
      rules: [{
        required: true,
        message: '请输入协议方式',
        trigger: 'blur'
      }]
    },
    {
      label: '直连(API)',
      prop: 'directConnection',
      type: 'switch',
      dicData: dict.yes_no,
      dataType: 'number',
      hide: true,
      display: false
    },
    {
      label: '全球格式',
      prop: 'proxyGlobalFormat',
      type: 'input',
      span: 24,
      showOverflowTooltip: true,
      rules: [{
        required: true,
        message: '请输入全球格式',
        trigger: 'blur'
      }]
    },
    {
      label: '国家格式',
      prop: 'proxyCountryFormat',
      type: 'input',
      span: 24,
      showOverflowTooltip: true,
      rules: [{
        required: true,
        message: '请输入国家格式',
        trigger: 'blur'
      }]
    },
    {
      label: '创建时间',
      prop: 'createTime',
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      startPlaceholder: '开始日期',
      endPlaceholder: '结束日期',
      width: 180,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      sortable: 'custom'
    },
    {
      label: '状态',
      prop: 'status',
      type: 'switch',
      dicData: dict.enable_disable,
      dataType: 'number',
      value: 1,
      search: true,
      searchSpan: 4,
      searchLabelWidth: 75,
      rules: [{
        required: true,
        message: '请输入状态',
        trigger: 'blur'
      }]
    }
  ]
};
